<?php

namespace App\Http\Resources\Index\Summary;

use App\Http\Resources\Resource;

class MonitoringResource extends Resource
{

    /**
     * Transform the resource into an array.
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        $collection = collect(parent::toArray($request));

        return $this->getResponse()->setResponseData([
            'online' => $collection->sum('online'),
            'online_ai' => $collection->sum('online_ai'),
            'gaming' => $collection->sum('gaming'),
            'gaming_ai' => $collection->sum('gaming_ai'),
            'infos' => $this->makeDatasOrg($collection->toArray())
        ]);
    }
}
